<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../react18/react.development.js"></script>
  <script src="../react18/react-dom.development.js"></script>
  <script src="../react18/babel.min.js"></script>
  <script src="../react18/prop-types.js"></script>
</head>

<body>
  <div id="app"></div>
  <script type="text/babel">
    /* 
      目前在没有路由的情况下,只能把react从容器中卸载出来 root.unmount
    
    
    */
    class App extends React.Component{
      render(){
        console.log("****render:组件挂载中****");
        return (
          <div>
            <h1>卸载流程</h1>
            <button onClick={this.unmountHandle}>卸载</button>  
          </div>
        )
      }

      unmountHandle = () => {
        root.unmount();
      }

      //常用:主要做收尾工作,清定时器 取消订阅 ...
      componentWillUnmount(){
        console.log("componentWillUnmount:组件即将卸载");
      }
    }

    const root = ReactDOM.createRoot(document.getElementById('app'));
    root.render(<App/>)

  </script>
</body>

</html>